

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>Grade Bay</title>
		<link rel="stylesheet" href="gui.css" type="text/css" />
		<!--[if IE 7]>
			<link rel="stylesheet" href="css/ie7.css" type="text/css" />
		<![endif]-->
	</head>
	<body>
		<div class="page">
			<div class="header">
				<a href="index.php" id="logo"><img src="images/gradeBaylogo.png" width="330" height="79" alt=""/></a>
				<ul>
					<li class="selected"><a href="">EDIT STUDENT</a></li>
				
				
				</ul>
			</div>
			<div class="body">
                         
				  <?php
                                       include 'PHPClasses/DBAccess.php';
                                       include 'PHPClasses/StudentDBAccess.php';
                                       include 'PHPClasses/Student.php';
                                    /*
                                    * To change this template, choose Tools | Templates
                                    * and open the template in the editor.
                                    */
                                       error_reporting(E_ERROR | E_PARSE);
                                       
                                        if (isset($_POST['submitted']))
                                { 
                                       $DBAccess=new StudentDBAccess();
                                       $Student=new Student();
                                      
                                     
                                        $Student->setIdStudent($_POST['studentID']);
                                        $Student->setStudentName($_POST["name"]);
                                        $Student->setStudentLevel($_POST['Level']);
                                        $Student->setAge($_POST['age']);
                                        $Student->setGender($_POST['gender']);
                                        $Student->setAddress($_POST['address']);
                                        $contact=$_POST["contact"];
                                
                                       
                                        $Student->setContactNum($contact);
                                        
                                        
                                    
                                       
                                        $errormsg=$DBAccess->validate($Student,TRUE);
                                       
                                        
                                       if ($errormsg){ //If any errors display them  
                                                header("Location: http://localhost/paragox-infinity-introse/editStudentProfile.php?error=".$errormsg."&studentID=".$Student->getIdStudent());
                                        }
                                       
                                        else
                                         {
                                                
                                                $DBAccess->updateDB($Student);
                                                $DBAccess->updateContactsDB($Student);
                                                        
                                                   echo "<script> 
                                                        if(confirm('Student updated! Forgot something?')){
                                                                window.location='http://localhost/paragox-infinity-introse/editStudentProfile.php?studentID=".$Student->getIdStudent()."';
                                                        }

                                                        else{
                                                            window.location='http://localhost/paragox-infinity-introse/viewStudentProfile.php?studentID=".$Student->getIdStudent()."';
                                                            }   

                                                        </script>"; 
            
                                       }
                                            $DBAccess->DBDisconnect();  
                                        
                                         

                        }
                                        
                 ?>
                             
				
			</div>
			
		</div>
	</body>
</html>  